<?php
header("content-type:text/html;charset=utf-8");
session_start();
include("conn/conn.php");
$names=$_POST["name"];
$pass=$_POST["password"];
$yzm1=$_SESSION['string'];

if($names=="" || $pass==""){
	echo("<script>alert('用户名或密码为空');window.location.href='gldenglu.php';</script>");
	}
	if(!preg_match('/^\w{2,15}$/',$names)){
	echo ("<script language='javascript'>alert('用户名格式不符合要求');window.location.href='gldenglu.php';</script>>");
	}
	if(strcasecmp($yzm1)==0){
$sql="select * from tb_guan where name='".$names."'and password='".$pass."'";
$result=mysqli_query($link,$sql);
if(mysqli_num_rows($result)>0){
	$rows_user=mysqli_fetch_assoc($result);
	$_SESSION['names']=$rows_user[name];
	echo("<script>alert('登录成功');window.location.href='pl_shoye.php';</script>");
}else{
	echo("<script>alert('打错账号或密码了呀');window.location.href='gldenglu.php';</script>");
}
	}
?>